const { getMyInfo } = require("../../api/myApi");

Page({
  /**
   * 页面的初始数据
   */
  data: {
    gnlbData: [
      {
        title: "我的积分",
        iconSrc: "../../public/images/iconImg/myIcon/jf.png",
      },
      {
        title: "优惠券",
        iconSrc: "../../public/images/iconImg/myIcon/yhq.png",
      },
      {
        title: "我的地址",
        iconSrc: "../../public/images/iconImg/myIcon/dz.png",
      },
      {
        title: "退款信息",
        iconSrc: "../../public/images/iconImg/myIcon/tk.png",
      },
      {
        title: "联系客服",
        iconSrc: "../../public/images/iconImg/myIcon/lxkf.png",
      },
      {
        title: "申请团长",
        iconSrc: "../../public/images/iconImg/myIcon/sqtz.png",
      },
      {
        title: "关于阳光百邦家政",
        iconSrc: "../../public/images/iconImg/myIcon/gy.png",
      },
    ],
    userInfoData: {},
  },

  // 获取我的信息
  async getMyInfoHandle() {
    const token = wx.getStorageSync("token");
    const res = await getMyInfo({ token });
    this.setData({
      userInfoData: res.data.data.user,
    });
    
  },

  // 点击跳转
  gnlbBtn(e) {
    switch (e.currentTarget.dataset.gnlbtitle) {
      case "我的积分":
        wx.navigateTo({
          url: "../integral/integral",
        });
        break;
      case "关于阳光百邦家政":
        wx.navigateTo({
          url: "../about/about",
        });
        break;
      default:
        break;
    }
  },

  // 去卡包
  cardPack() {
    wx.navigateTo({
      url: "../cardPack/cardPack",
    });
  },

  // 去我的信息
  infoBtn() {
    wx.navigateTo({
      url: "../myinfo/myinfo",
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getMyInfoHandle();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
